﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Enter.Entity;
using Enter.Common;
using Enter.BizLogic;
using Enter.Config;
using Enter.Web.SystemAdmin;
namespace WebSystemAdmin.GoodClass
{
    public partial class GoodBrandIndexEdit : PageBase
    {

        public int ID = RequestStrHelper.GetIntFromRequest("ID", 0);
        protected void Page_Load(object sender, EventArgs e)
        {
            ListCtrlHelper.BindEnumOnListControl(ddl_Status, typeof(T110_GoodBrandIndexEntity.EnumStatus));
            if (!IsPostBack)
            {
                if (ID != 0)
                {
                    GetInfo();
                }
            }
        }

        private void GetInfo()
        {
            T110_GoodBrandIndexBLLSub bll = new T110_GoodBrandIndexBLLSub();
            T110_GoodBrandIndexEntity model = bll.GetObjectByID(int.Parse(Request.QueryString["ID"]));
            if (model == null) return;
            txt_ID.Text = model.ID.ToString();
            txt_BID.Text = model.BID.ToString();
            txt_ImgUrl.Text = model.ImgUrl.ToString();
            txt_Weight.Text = model.Weight.ToString();
            txt_StartTime.Text = model.StartTime.ToString();
            txt_EndTime.Text = model.EndTime.ToString();
            this.ddl_Status.Items.FindByValue(((byte)model.Status).ToString()).Selected = true;
            txt_Des.Text = model.Des.ToString();
            txt_AddTime.Text = model.AddTime.ToString();
        }

        protected void btnApply_Click(object sender, EventArgs e)
        {
            T110_GoodBrandIndexEntity model = new T110_GoodBrandIndexEntity();
            T110_GoodBrandIndexBLLSub bll = new T110_GoodBrandIndexBLLSub();
            if (Request.QueryString["ID"] != null)
            {
                model.ID = ID;
            }
            model.BID = int.Parse(txt_BID.Text);
            model.ImgUrl = txt_ImgUrl.Text;
            model.Weight = int.Parse(txt_Weight.Text);
            model.StartTime = DateTime.Parse(txt_StartTime.Text);
            model.EndTime = DateTime.Parse(txt_EndTime.Text);
            model.Status = (T110_GoodBrandIndexEntity.EnumStatus)byte.Parse(ddl_Status.SelectedValue);
            model.Des = txt_Des.Text;
            model.AddTime = DateTime.Parse(txt_AddTime.Text);
            if (bll.Save(model))
            {
                Utils.throwErrorGotoURL("添加成功", "GoodBrandIndexList.aspx");
            }
            else
            {
                Utils.ShowMessage("添加失败");
            }
        }
    }
}
